package org.example.hansp.genetic.details;

import java.util.ArrayList;
import java.util.List;

/*
* 在给泛型指定类型后，可以传入指定类型和其子类类型
* 泛型的使用形式*/
public class GenericDetails01 {
    public static void main(String[] args) {
        A<Animal> animalA = new A<Animal>(new Animal());
       animalA.f();
        A<Animal> a = new A<>(new Dog());
        a.f();
        ArrayList<Animal> animals = new ArrayList<>();
        List<Animal> dogs = new ArrayList<>();
    }
}
class Animal{

}
class Dog extends Animal{

}
class Cat extends Animal{

}
class A<E>{
    E e;

    public A(E e) {
        this.e = e;
    }
public void f(){
    System.out.println(e.getClass());
}
}